<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>院校联系人列表</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <!--link导入外部的css，js样式，如果导入的资源和本页面在同一个文件夹下，直接文件名即可-->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- jQuery 3 -->
    <script th:src="@{/asserts/bower_components/jquery/dist/jquery.min.js}"></script>
    <!-- Bootstrap 3.3.7 -->
    <script th:src="@{/asserts/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- DataTables -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/asserts/dist/css/AdminLTE.min.css}">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/asserts/dist/css/skins/_all-skins.min.css}">
    <script th:src="@{/asserts/Apolar_sh/lib/layer/2.4/layer.js}"></script>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->

    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
    <style type="text/css">
        .search {
            margin-top: 40px;
            margin-left: 40px;
            position: relative;
        }

        td {
            text-align: center;
        }

        th {
            text-align: center;
        }
        #home {
            display: block;
            position: absolute;
            right: 10px;
            top: 8px;
            z-index: 9999;
            font-size: 30px;
        }

        #refresh {
            display: block;
            position: absolute;
            right: 46px;
            top: 10px;
            z-index: 9999;
            font-size: 26px;
        }
    </style>

</head>
<body>
<span>
    <a id="refresh" class="fa fa-refresh"  href="javascript:location.reload()"></a>
    <a id="home" class="fa fa-home" th:href="@{/campus/infoFindAll}"></a>
</span>

<div class="wrapper">
    <!-- Content Wrapper. Contains page content -->
    <!-- Content Header (Page header) -->
    <!-- Main content -->
    <section class="content-header">
        <h4>
            <i class="fa fa-navicon"></i> 院校联系人列表
        </h4>

    </section>
    <div class="search">

        <div class="row">
            <div class="col-xs-3">
                <h4 th:text="|院校名称: ${campusName}|">院校名称：清华大学</h4>
            </div>
            <div class="col-xs-2">
                <a class="btn btn-info"
                   th:href="@{/CampusConn/saveUI(campusName=${campusName},campusId=${campusId},RcurrentPage=${RcurrentPage},RpageSize=${RpageSize})}">
                    <i class="fa fa-plus"></i> 添加联系人信息
                </a>
            </div>
            <div class="col-xs-2" th:if="${info != null}">
                <a class="btn btn-info"
                   th:href="@{/campus/infoFindAll(currentPage=${RcurrentPage},pageSize=${RpageSize})}">
                    <i class="fa fa-backward"></i> 返回
                </a>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </div>

    <!-- /.content -->
</div>

<div class="wrapper">
    <div th:if="${info != null}" style="width: 270px;margin: auto">
        <p style="color: #ff0000;font-size: 30px;font-weight: bold">[[${info}]]</p>
    </div>
    <div class="box-body" th:if="${info == null}">
        <form method="post"
              th:action="@{/CampusConn/deleteAll(campusId=${campusId},RcurrentPage=${RcurrentPage},RpageSize=${RpageSize})}">
            <table id="example1" class="table table-bordered table-hover">
                <tbody>
                <tr>
                    <th th:if="${session.user.authority != 3}">选择</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>职务</th>
                    <th>渠道专员</th>
                    <th>联系方式</th>
                    <th>个人情况</th>
                    <th>备注</th>
                    <th>创建时间</th>
                    <th>修改时间</th>
                    <th>操作</th>
                </tr>
                <tr th:each="campusConn:${pageBean.list}">
                    <td th:if="${session.user.authority != 3}">
                        <input type="checkbox" name="campusConnIds" class="checks"
                               th:value="${campusConn.campusConnId}"/>
                    </td>
                    <td th:text="${campusConn.campusConnName}">张三</td>
                    <td th:text="${campusConn.campusConnSex}">男</td>
                    <td th:text="${campusConn.campusConnPosition}">院长</td>
                    <td th:text="${campusConn.personname}">张老师</td>
                    <td th:text="${campusConn.campusConnWay}">13812349999, 0512-629559999</td>
                    <td>
                        <a class="btn btn-info" data-toggle="modal"
                           th:data-target="'#'+${campusConn.campusConnId}">
                            <i class="fa fa-info"></i> 个人情况
                        </a>
                        <!-- Modal -->
                        <div class="modal fade" th:id="${campusConn.campusConnId}" tabindex="-1" role="dialog"
                             aria-labelledby="myModalLabel">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal"
                                                aria-label="Close"><span aria-hidden="true">&times;</span>
                                        </button>
                                        <h4 class="modal-title"><i class="fa fa-info"></i>
                                            个人情况</h4>
                                    </div>
                                    <div class="modal-body">
                                        <div class="form-group">
                                            <table>
                                                <tr>
                                                    <td th:text="${campusConn.campusConnPersonal}"></td>
                                                </tr>
                                            </table>

                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-default"
                                                    data-dismiss="modal">确定
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </td>
                    <td th:text="${campusConn.campusConnRemarks}">主持工作</td>
                    <td th:text="${#dates.format(campusConn.campusConnCreateDate, 'yyyy-MM-dd')}">2019-06-28</td>
                    <td th:text="${#dates.format(campusConn.campusConnModifyDate, 'yyyy-MM-dd')}">2019-07-22</td>
                    <td>
                        <a class="btn btn-warning"
                           th:href="@{/CampusConn/updateUI(campusConnId=${campusConn.campusConnId},campusName=${campusName},RcurrentPage=${RcurrentPage},RpageSize=${RpageSize})}">
                            <i class="fa fa-edit"></i> 修改
                        </a>
                        <a class="btn btn-danger" th:onclick="deleteById([[${campusConn.campusConnId}]])"
                           th:if="${session.user.authority != 3}">
                            <i class="fa fa-trash"></i> 删除
                        </a>
                    </td>
                </tr>
                <tr>
                    <td th:if="${session.user.authority != 3}">
                        <label><input type="checkbox" name="" id="all" value=""/>&nbsp;&nbsp;全选</label>

                    </td>
                    <td colspan="13" style="text-align:left;padding-left:20px;">
                        <button th:if="${session.user.authority != 3}" class="btn btn-danger"
                                onclick="return confirm('确认要删除？')" type="submit">
                            <i class="fa fa-trash"></i> 删除
                        </button>&nbsp;&nbsp;
                        <a class="btn btn-info"
                           th:href="@{/campus/infoFindAll(currentPage=${RcurrentPage},pageSize=${RpageSize})}">
                            <i class="fa fa-backward"></i> 返回
                        </a>
                    </td>
                </tr>
                <tr>

                </tr>
                </tbody>
            </table>
        </form>
        <!-- 分页 -->
        <nav aria-label="Page navigation">
            <ul class="pagination">
                <li>
                    <a th:if="${pageBean.pageNum != 1 }"
                       th:href="@{/CampusConn/findAll(currentPage=1, campusId=${campusId},RcurrentPage=${RcurrentPage},RpageSize=${RpageSize})}">首页</a>
                </li>
                <li>
                    <a th:if="${pageBean.pageNum==1 }"
                       href="javascript:void(0)">首页</a>
                </li>

                <li th:if="${pageBean.pageNum!=1 }">
                    <a th:href="@{/CampusConn/findAll(currentPage=${pageBean.pageNum-1}, campusId=${campusId},RcurrentPage=${RcurrentPage},RpageSize=${RpageSize})}"
                       aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
                <li class="disabled" th:if="${pageBean.pageNum==1 }">
                    <a href="javascript:void(0)" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>

                <li th:classappend="${pageBean.pageNum==pageIndex}?'active':''"
                    th:each="pageIndex:${pageValue}">
                    <a
                            th:if="${pageBean.pageNum==pageIndex}"
                            th:text="${pageIndex}"></a>
                    <a th:if="${pageIndex==-1}" style="cursor: default;opacity: 0.6;">
                        ...
                    </a>
                    <a th:if="${pageBean.pageNum!=pageIndex&&pageIndex!=-1}"
                       th:href="@{/CampusConn/findAll(currentPage=${pageIndex}, campusId=${campusId},RcurrentPage=${RcurrentPage},RpageSize=${RpageSize})}"
                       th:text="${pageIndex}"></a>
                </li>

                <li class="disabled" th:if="${pageBean.pageNum==pageBean.pages }">
                    <a href="javascript:void(0)" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
                <li th:if="${pageBean.pageNum!=pageBean.pages }">
                    <a th:href="@{/CampusConn/findAll(currentPage=${pageBean.pageNum+1}, campusId=${campusId},RcurrentPage=${RcurrentPage},RpageSize=${RpageSize})}"
                       aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>

                <li>
                    <a th:if="${pageBean.pageNum!=pageBean.pages }"
                       th:href="@{/CampusConn/findAll(currentPage=${pageBean.pages}, campusId=${campusId},RcurrentPage=${RcurrentPage},RpageSize=${RpageSize})}">末页</a>
                </li>
                <li>
                    <a th:if="${pageBean.pageNum==pageBean.pages }"
                       href="javascript:void(0)">末页</a>
                </li>

            </ul>
        </nav>
        <input id="currentPage" th:value="${pageBean.pageNum}" hidden>
        <input id="currentPageSize" th:value="${pageBean.size}" hidden>
        <input id="lastPage" th:value="${pageBean.pages}" hidden>
        <input id="campusId" th:value="${campusId}" hidden>
        <input id="RcurrentPage" th:value="${RcurrentPage}" hidden>
        <input id="RpageSize" th:value="${RpageSize}" hidden>
    </div>
    <!-- /.box-body -->

</div>


<!-- /.box -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>

<!-- ./wrapper -->


<!-- DataTables -->
<script th:src="@{/asserts/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/asserts/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/asserts/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/asserts/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/asserts/dist/js/adminlte.min.js}"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/asserts/dist/js/demo.js}"></script>
<!-- page script -->
<script>
    $("#all").click(function () {
        if (this.checked) {
            $(".checks").prop("checked", true);
            $("#all").prop("value", "全不选");
        } else {
            $(".checks").prop("checked", false);
            $("#all").prop("value", "全选");
        }
    });
    function deleteById(connId) {
        layer.confirm("确认删除？",
            {
                btn: ['确定', '取消'] //按钮
            },
            function () {
                var currentPageSize = $("#currentPageSize").val();
                var currentPage = $("#currentPage").val();
                var lastPage = $("#lastPage").val();
                var campusId=$("#campusId").val();
                var RcurrentPage=$("#RcurrentPage").val();
                var RpageSize=$("#RpageSize").val();
                $.ajax({
                    url: '[[${#httpServletRequest.getContextPath()}]]/CampusConn/delete?currentPageSize=' + currentPageSize + '&currentPage=' + currentPage + '&lastPage=' + lastPage,
                    data: {
                        'campusConnId': connId
                    },
                    success: function (result) {
                        console.log(result);
                        if (result == '1') {
                            layer.msg('删除成功！', {icon: 1, time: 1000});
                            location.reload();
                        }else if (result == '0') {
                            layer.msg('删除成功！', {icon: 1, time: 1000});
                            location.replace("[[${#httpServletRequest.getContextPath()}]]/CampusConn/findAll?currentPage=" + (currentPage - 1) + "&campusId=" + campusId + "&RcurrentPage=" + RcurrentPage + "&RpageSize=" + RpageSize);
                        }
                        else {
                            layer.msg('删除失败！', {icon: 0, time: 1000});
                        }

                    }
                })
            },
            function () {
                layer.msg('已取消！', {icon: 0, time: 500});
                return false;
            }
        );
    };
</script>
</body>
</html>